package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.SoulQuestionMapper;
import com.tanhua.model.domain.SoulQuestion;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 问卷问题的数据层实现类
 *
 * @author 李磊
 * @since 2022-01-14 10:00
 */
@DubboService
public class SoulQuestionApiImpl implements SoulQuestionApi {

    @Autowired
    SoulQuestionMapper soulQuestionMapper;

    /**
     * 说明:  根据试卷id查询对应的所有题目
     *
     * @param questionnaireId 试卷id
     * @return java.util.List<com.tanhua.model.domain.SoulQuestion>
     * @author 李磊
     * @since 2022-01-14 13:18
     */
    @Override
    public List<SoulQuestion> findByQuestionnaireId(Long questionnaireId) {

        LambdaQueryWrapper<SoulQuestion> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SoulQuestion::getQuestionnaireId,questionnaireId);
        return soulQuestionMapper.selectList(wrapper);
    }

    /**
     * 说明:  根据id进行问题查询并返回
     *
     * @param questionId 问题id
     * @return com.tanhua.model.domain.SoulQuestion
     * @author 李磊
     * @since 2022-01-14 17:49
     */
    @Override
    public SoulQuestion findById(Long questionId) {
        return soulQuestionMapper.selectById(questionId);
    }
}
